package com.xuexiang.yoyo.sql.mapper;

import android.content.ContentValues;

import com.xuexiang.yoyo.constant.HesAppStatic;
import com.xuexiang.yoyo.entity.Log;

import java.time.LocalDateTime;


public class LogMapper {
    public static final String TABLE = "log";
    public static final String CREATE_TABLE_SQL="CREATE TABLE "+ TABLE +"(id INTEGER PRIMARY KEY AUTOINCREMENT," +
            "device_code TEXT," +
            "data_time TEXT," +
            "type TEXT," +
            "content TEXT" +
            ");";


    public static void insert(Log log){
        ContentValues contentValues = new ContentValues();
        contentValues.put("device_code", log.getDeviceCode());
        contentValues.put("content", log.getContent());
        contentValues.put("data_time", LocalDateTime.now().toString());
        contentValues.put("type", log.getType());
        HesAppStatic.getmDataBaseOpenHelper().insert(TABLE,contentValues);
    }

    public static void insert(String deviceCode, String type, String content){
        Log log = new Log();
        log.setDeviceCode(deviceCode);
        log.setContent(content);
        log.setType(type);
        insert(log);
    }
}
